//解密公钥
var publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcaVfbycoF4yfXfSY6x6dOijO8in2Ibe9XKxYU64wZnczTCv32AkEQty2U777jpswOmsQSqQ + wZrkBftgmSNq + u0d3HEvVFmSALSI7u / MLrHHHYBggTi2iisDRAn0wjRMzsm1 + prFPjV4tFSe1 + HPeH0DvZFfyaGOgXJ7hsqp2dwIDAQAB";
//登录 后的提交对象
var pro = {};
//登录前的提交对象
var obj = {};
//版本等常量设定
var edition_type = 'pro';
var var_client = "h5";
var var_version = "1.0";
var url_host = 'http://test.dianliubao.com/';//'http://appdev.ly.ai/'; //http://192.168.1.102/
if (edition_type == 'dev') {
	url_host = "http://test.dianliubao.com/";
} else if (edition_type == 'pro') {
	url_host = "https://dianliubao.com/";
}
//登录后的用户信息
var user_info = {};
//console.log(user_info);
//初始化本地存储
var storage = window.localStorage;

var VIDEO_PIRX = 'dlb_safe_';
var VIDEO_TOKEN = VIDEO_PIRX + 'token';

var VIDEO_APPKEY = '438286e917674c10a62c75845854fc5f';
var VIDEO_SECRET = 'bd2b967103e635a930f1402b75211bde';

//登录后的参数对象AES加密
function official_login_after(xurl, xparams, xtoken, avatar) {

	console.log(" ");
	console.log(xtoken + "-----------------以下是登录后请求数据>>>>>>>>>>");
	console.log(xparams); //打印用户提交的数据	

	pro.token = user_info.token;
	pro.secret_accept = user_info.secret_accept;
	pro.secret_response = user_info.secret_response;
	pro.avatar = user_info.avatar;
	pro.id = user_info.id;
	//前方传来的参数
	var params = xparams;
	pro.client = var_client;
	pro.version = var_version;
	pro.params = encrypt_xaccept(pro.secret_accept, params);
	pro.sign = CryptoJS.MD5(objKeySort(params)).toString();
	if(avatar == null) {
		ajax_submit_after(xurl, xtoken, avatar);
	} else {
		ajax_submit_after_file(xurl, xtoken, avatar);
	}

	return;
}

//登录后的对象ajax提交
function ajax_submit_after_file(xurl, xtoken, avatar) {
	//alert("准备上传文件");
	//	var form = new FormData();
	//	form.append("avatar", FormData($('#uploadForm')[0]);
	//	form.append("id", pro.id);　
	//	form.append("token", pro.token);　
	//	form.append("client", pro.client);　
	//	form.append("version", pro.version);　
	//	form.append("params", pro.params);　
	//	form.append("sign", pro.sign);　

	$('#id').val(pro.id);
	$('#token').val(pro.token);
	$('#client').val(pro.client);
	$('#version').val(pro.version);
	$('#params').val(pro.params);
	$('#sign').val(pro.sign);

	$.ajax({
		url: xurl,
		type: "post",
		data: new FormData(document.getElementById("uploadForm")),
		processData: false,
		contentType: false,
		success: function(data) {
			console.log(data);
			mui.alert(data.message);

			//服务器返回响应，根据响应结果，分析是否登录成功；
			if(data.status == 200) {
				//aes解密
				var decrypt = CryptoJS.AES.decrypt(data.data, CryptoJS.enc.Utf8.parse(pro.secret_response), {
					mode: CryptoJS.mode.ECB,
					padding: CryptoJS.pad.Pkcs7
				});
				var json = JSON.parse(decrypt.toString(CryptoJS.enc.Utf8))

				//修改每次获取的token值
				user_info.token = json.token;
				user_info.avatar = json.url;

				//				console.log("ok1");
				//				console.log(user_info);
				//将存储成 json对象
				window.localStorage.setItem("user_info", JSON.stringify(user_info));
				//赋值过程---开始给界面标签赋值--------------------------------------------
				//我的
				if(xtoken == 'mine_avatar_upload') {
					$('#mine-logo').attr('src', json.url);
					mine_modify(json.url);
				}
			} else {

			}

		}
	});

}

//登录后的对象ajax提交
function ajax_submit_after(xurl, xtoken, avatar) {

	mui.ajax(xurl, {
		data: {
			"avatar": avatar,
			'id': pro.id,
			'token': pro.token,
			'client': pro.client,
			'version': pro.version,
			'params': pro.params, //"AES 加密后的参数数据"
			"sign": pro.sign, //"签名：params 加密之前的数据按【a-z】的顺序排序后 md5的结果"
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 30000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		success: function(data) {
			//服务器返回响应，根据响应结果，分析是否登录成功；
			if(data.status == 200) {
				//aes解密
				var decrypt = CryptoJS.AES.decrypt(data.data, CryptoJS.enc.Utf8.parse(pro.secret_response), {
					mode: CryptoJS.mode.ECB,
					padding: CryptoJS.pad.Pkcs7
				});
				var json = JSON.parse(decrypt.toString(CryptoJS.enc.Utf8))
				console.log(" ");
				console.log("---------------->>>print json--------->>>>" + xurl);
				console.log(json);
				//				console.log("ok2");
				//				console.log(user_info);

				//登录成功，将用户信息进行本地储存
				//修改每次获取的token值
				user_info.token = json.token;
				//将存储成 json对象
				window.localStorage.setItem("user_info", JSON.stringify(user_info));
				//赋值过程---开始给界面标签赋值--------------------------------------------
				
				if(xtoken=='mine_info_agree'){
					user_info.agree = '1';
					//将存储成 json对象
					window.localStorage.setItem("user_info", JSON.stringify(user_info)); //但是返回[object Object]
					location.href = 'index.html';
				}else if(xtoken == 'mine_info') {
					//我的
					//xmine.editor = {};
					//修改每次获取的 个人信息资料
					user_info.avatar = json.avatar; //"http://xxx.jpg"
					user_info.email = json.email; //"aaa@aaa.com"
					user_info.gender = json.gender; //"男"
					user_info.phone = json.phone; //"18888888888"
					user_info.real_name = json.real_name; //"张三"
					user_info.token = json.token; //"be4691e7b800d264b5074ab4ab4c38ad";
					user_info.agree = json.agree;


					//将存储成 json对象
					window.localStorage.setItem("user_info", JSON.stringify(user_info));
					//console.log(user_info);

					//首页的------------信息
				} else if(xtoken == 'main') {

					//下面标签统计量系列
					var str = '';
					var xarr = json.chart;
					mui("#index-cumulative_month-name")[0].innerHTML = xarr.cumulative_month.value;
//					mui("#operating_cost")[0].innerHTML = xarr.operating_cost.value;
					//mui("#index-expenditure-name")[0].innerHTML = xarr.expenditure.value;

					//营业利润
					mui("#index-turnover_rate-name")[0].innerHTML = xarr.turnover.value.replace("-", "");
					//console.log(xarr.turnover_rate.value);
//					iis_rise('#index-turnover_rate-name', xarr.turnover_rate.is_rise, 1);
					iis_rise('#index-turnover_rate-pic', xarr.turnover.is_rise, 0);
//					iis_rise('#index-xiaoguo-pic', xarr.turnover_rate.is_rise, 2);
					//三个方块的内容
					//进行色彩的变化与图标变化
					iis_rise('#index-turnover-name', xarr.member.is_rise, 1);
					iis_rise('#index-turnover-compare_rate', xarr.member.is_rise, 1);
					iis_rise('#index-turnover-pic', xarr.member.is_rise, 0);
					mui("#index-turnover-name")[0].innerHTML = xarr.member.value;
					mui("#index-turnover-compare_rate")[0].innerHTML = xarr.member.compare_rate + "%";
					//进行色彩的变化与图标变化
					iis_rise('#index-passenger-name', xarr.passenger.is_rise, 1);
					iis_rise('#index-passenger-compare_rate', xarr.passenger.is_rise, 1);
					iis_rise('#index-passenger-pic', xarr.passenger.is_rise, 0);
					mui("#index-passenger-name")[0].innerHTML = xarr.passenger.value;
					mui("#index-passenger-compare_rate")[0].innerHTML = xarr.passenger.compare_rate + "%";
					//进行色彩的变化与图标变化
					iis_rise('#index-volume_rate-name', xarr.volume_rate.is_rise, 1);
					iis_rise('#index-volume_rate-compare_rate', xarr.volume_rate.is_rise, 1);
					iis_rise('#index-volume_rate-pic', xarr.volume_rate.is_rise, 0);
					mui("#index-volume_rate-name")[0].innerHTML = xarr.volume_rate.value;
					mui("#index-volume_rate-compare_rate")[0].innerHTML = xarr.volume_rate.compare_rate + "%";
					//下面的是图表系列--"客流量VS营业额走势图"
					var str = '';
					var xarr = json.graphic.data1;

					var option = null;
					var mychart = echarts.init($('#mychart')[0]);
					//var option = chart_zx_and_zz(xarr, index2, '', 0);
					if (xarr.line.length == 2) {
						option = chart_zx_and_zx_axLine_y_100(xarr,keliuVsyinye);
					} else {
						option = chart_zx_only_bj_axLine_y_100(xarr,keliuVsyinye);
					}
					mychart.setOption(option);

					//下面的是图表系列--""客流量VS成交率走势图""
					var str = '';
					var xarr2 = json.graphic.data2;

					var mychart2 = echarts.init($('#mychart2')[0]);
					var option2 = null;
					//var option2 = chart_zx_and_zz(xarr2, index3, '%', 100);
					if (xarr.line.length == 2) {
						option2 = chart_zx_and_zx_axLine_y_100(xarr2,keliuVschengjiao);
					} else {
						option2 = chart_zx_only_bj_axLine_y_100(xarr2,keliuVschengjiao);
					}
					mychart2.setOption(option2);

					//首页的-----------门店列表
				} else if(xtoken == 'shop_lists_index') {
					mui("#list-shop-lists")[0].innerHTML = '';
					user_info.shop_list = json.lists;
					//将存储成 json对象
					window.localStorage.setItem("user_info", JSON.stringify(user_info));

					//pos数据录入	
				} else if(xtoken == 'pos_write_input') {
					mui.alert("添加成功");
					mui("#index_price")[0].value = "";
					mui("#index_fixture_count")[0].value = "";
					mui("#index_sales_count")[0].value = "";
					mui("#index_cost_price")[0].value = "";
					document.getElementById("btn_login1").disabled = true;

					//支出数据录入	
				} else if(xtoken == 'pos_write_output') {
					mui.alert("添加成功");

					mui("#price")[0].value = "";
					mui("#reason")[0].value = "";
					document.getElementById("btn_login2").disabled = true;
					//
					//首页的------------营业额信息
				} else if(xtoken == 'statistics_turnover') {

					//下面标签统计量系列
					var str = '';
					var xarr = json.chart;
					//进行色彩的变化与图标变化
					iis_rise('#index-yingyee-turnover', xarr.turnover.is_rise, 1);
					iis_rise('#index-yingyee-turnover-compare_rate', xarr.turnover.is_rise, 1);
					iis_rise('#index-yingyee-turnover-pic', xarr.turnover.is_rise, 0);
					mui("#index-yingyee-turnover")[0].innerHTML = xarr.turnover.value;
					mui("#index-yingyee-turnover-compare_rate")[0].innerHTML = xarr.turnover.compare_rate;
					//进行色彩的变化与图标变化
					iis_rise('#index-yingyee-unit_price', xarr.unit_price.is_rise, 1);
					iis_rise('#index-yingyee-unit_price-compare_rate', xarr.unit_price.is_rise, 1);
					iis_rise('#index-yingyee-unit_price-pic', xarr.unit_price.is_rise, 0);
					mui("#index-yingyee-unit_price")[0].innerHTML = xarr.unit_price.value;
					mui("#index-yingyee-unit_price-compare_rate")[0].innerHTML = xarr.unit_price.compare_rate;
					//进行色彩的变化与图标变化
					iis_rise('#index-yingyee-joint_rate', xarr.joint_rate.is_rise, 1);
					iis_rise('#index-yingyee-joint_rate-compare_rate', xarr.joint_rate.is_rise, 1);
					iis_rise('#index-yingyee-joint_rate-pic', xarr.joint_rate.is_rise, 0);
					mui("#index-yingyee-joint_rate")[0].innerHTML = xarr.joint_rate.value;
					mui("#index-yingyee-joint_rate-compare_rate")[0].innerHTML = xarr.joint_rate.compare_rate;
					//下面的是图表系列--"营业额走势图"
					var str = '';
					var xarr = json.graphic.turnover;
					//					mui("#index-graphic-data1-name")[0].innerHTML = yarr_1.name;
					//					chart_zx_only_bj(xarr, 'statistics_turnover1');
					var mychart = echarts.init($('#mychart')[0]);
					var option = chart_zx_only_bj(xarr);
					mychart.setOption(option);

					//下面标签统计量系列
					var str = '';
					var xarr = json.new_old_chart.new_guest;;
					mui("#new_guest_rate")[0].innerHTML = xarr.rate + "%";
					mui("#new_guest_price")[0].innerHTML = xarr.price;
					mui("#new_guest_personnel")[0].innerHTML = xarr.personnel;
					//下面的是图表系列--“新客的饼图”
					var str = '';
					var yarr_new = json.new_old_chart.new_guest;
					var yarr_old = json.new_old_chart.old_guest;

					Pie_arr = [json.new_old_chart.new_guest, json.new_old_chart.old_guest];
					Pie_arr[0]['value'] = Pie_arr[0]['rate'];
					Pie_arr[1]['value'] = Pie_arr[1]['rate'];
					// 使用  
					chart_pie_eConsole();
					//					require(
					//						[
					//							'echarts',
					//							'echarts/chart/pie'
					//						], DrawCharts);

					//console.log(Pie_arr);

					//首页的------------成交率
				} else if(xtoken == 'statistics_turnoverrate') {

					//下面标签统计量系列
					var str = '';
					var xarr = json.chart;
					//进行色彩的变化与图标变化
					iis_rise('#index-chengjiaolv-turnover_count', xarr.turnover_count.is_rise, 1);
					iis_rise('#index-chengjiaolv-turnover_count-compare_rate', xarr.turnover_count.is_rise, 1);
					iis_rise('#index-chengjiaolv-turnover_count-pic', xarr.turnover_count.is_rise, 0);
					mui("#index-chengjiaolv-turnover_count")[0].innerHTML = xarr.turnover_count.value;
					mui("#index-chengjiaolv-turnover_count-compare_rate")[0].innerHTML = xarr.turnover_count.compare_rate + "%";
					//进行色彩的变化与图标变化
					iis_rise('#index-chengjiaolv-turnover_rate', xarr.turnover_rate.is_rise, 1);
					iis_rise('#index-chengjiaolv-turnover_rate-compare_rate', xarr.turnover_rate.is_rise, 1);
					iis_rise('#index-chengjiaolv-turnover_rate-pic', xarr.turnover_rate.is_rise, 0);
					mui("#index-chengjiaolv-turnover_rate")[0].innerHTML = xarr.turnover_rate.value;
					mui("#index-chengjiaolv-turnover_rate-compare_rate")[0].innerHTML = xarr.turnover_rate.compare_rate + "%";
					//进行色彩的变化与图标变化
					iis_rise('#index-chengjiaolv-unit_price', xarr.unit_price.is_rise, 1);
					iis_rise('#index-chengjiaolv-unit_price-compare_rate', xarr.unit_price.is_rise, 1);
					iis_rise('#index-chengjiaolv-unit_price-pic', xarr.unit_price.is_rise, 0);
					mui("#index-chengjiaolv-unit_price")[0].innerHTML = xarr.unit_price.value;
					mui("#index-chengjiaolv-unit_price-compare_rate")[0].innerHTML = xarr.unit_price.compare_rate + "%";
					//下面的是图表系列--"成交率走势图"
					var str = '';
					var xarr = json.graphic.turnover_rate;
					//					mui("#index-graphic-data1-name")[0].innerHTML = yarr_1.name;
					//					yarr_1.line = ['成交率', '成交率']; //-------------------------------------------后台没有提供，自己设置一个
					//					chart_zx_only_bj(yarr_1, 'statistics_turnover1');
					var mychart = echarts.init($('#mychart')[0]);
					var option = chart_zx_only_bj(xarr);
					mychart.setOption(option);

					//首页的------------客流量
				} else if(xtoken == 'statistics_passenger') {

					//下面标签统计量系列
					var str = '';
					var xarr = json.chart;
					//进行色彩的变化与图标变化---客流量
					iis_rise('#index-keliuliang-passenger', xarr.passenger.is_rise, 1);
					iis_rise('#index-keliuliang-passenger-compare_rate', xarr.passenger.is_rise, 1);
					iis_rise('#index-keliuliang-passenger-pic', xarr.passenger.is_rise, 0);
					mui("#index-keliuliang-passenger")[0].innerHTML = xarr.passenger.value;
					mui("#index-keliuliang-passenger-compare_rate")[0].innerHTML = xarr.passenger.compare_rate;
					//进行色彩的变化与图标变化---老客
					iis_rise('#index-keliuliang-old_guest', xarr.old_guest.is_rise, 1);
					iis_rise('#index-keliuliang-old_guest-compare_rate', xarr.old_guest.is_rise, 1);
					iis_rise('#index-keliuliang-old_guest-pic', xarr.old_guest.is_rise, 0);
					mui("#index-keliuliang-old_guest")[0].innerHTML = xarr.old_guest.value;
					mui("#index-keliuliang-old_guest-compare_rate")[0].innerHTML = xarr.old_guest.compare_rate;
					//进行色彩的变化与图标变化---会员
					iis_rise('#index-keliuliang-return_guest', xarr.member.is_rise, 1);
					iis_rise('#index-keliuliang-return_guest-compare_rate', xarr.member.is_rise, 1);
					iis_rise('#index-keliuliang-return_guest-pic', xarr.member.is_rise, 0);
					mui("#index-keliuliang-return_guest")[0].innerHTML = xarr.member.value;
					mui("#index-keliuliang-return_guest-compare_rate")[0].innerHTML = xarr.member.compare_rate;
					//下面的是图表系列--"客流量走势图"
					var str = '';
					var xarr = json.graphic.passenger;
					//mui("#index-graphic-data1-name")[0].innerHTML = yarr_1.name;
					//chart_zx_only_bj(yarr_1, 'statistics_turnover1');
					var mychart = echarts.init($('#mychart')[0]);
					var option = chart_zx_only_bj(xarr);
					mychart.setOption(option);

					//下面的是图表系列--"新增客流量走势图"
					var str = '';
					var xarr2 = json.graphic.new_guest;
					//					mui("#index-graphic-data2-name")[0].innerHTML = yarr_2.name;
					//					chart_zx_only_bj(yarr_1, 'statistics_turnover2');
					var mychart2 = echarts.init($('#mychart2')[0]);
					var option2 = chart_zx_only_bj(xarr2);
					mychart2.setOption(option2);
					//下面的是图表系列--"男女走势"
					var yarr_new = json.graphic2.gender_rate.data;
					var yarr_old = json.graphic2.gender_rate.data;
					chart_pie_only(30, yarr_new[0].name, yarr_old[1].name, yarr_new[0].data[0], yarr_old[1].data[0], 'statistics_turnover3a');
					//下面的是图表系列--"新老走势"
					var yarr_new = json.graphic2.guest_rate.data[0];
					var yarr_old = json.graphic2.guest_rate.data[1];
					chart_pie_only(30, yarr_new.name, yarr_old.name, yarr_new.data[0], yarr_old.data[0], 'statistics_turnover3b');
					//下面的是图表系列--"年龄走势"

					var yarr_3c = json.graphic2.age_rate;
					var mychart3 = echarts.init($('#mychart3')[0]);
					var option3 = chart_zz_only_noxAxis_noxLines(yarr_3c);
					mychart3.setOption(option3);

					//下面是倒三解的比例值
//					mui("#index-keliuliang-s_chart-conversion_rate-into")[0].innerHTML = json.s_chart.conversion_rate.into + "%";
//					mui("#index-keliuliang-s_chart-conversion_rate-deal")[0].innerHTML = json.s_chart.conversion_rate.deal + "%";
//					mui("#index-keliuliang-s_chart-passenger")[0].innerHTML = json.s_chart.passenger.value;
//					mui("#index-keliuliang-s_chart-total_people")[0].innerHTML = json.s_chart.total_people.value;
//					mui("#index-keliuliang-s_chart-turnover_count")[0].innerHTML = json.s_chart.turnover_count.value;
					//首页的------------指标查询
				} else if(xtoken == 'statistics_quota') {
					//下面的是图表系列--"指标查询"
					var str = '';
					var xarr = json.graphic.data1;

					var mychart = echarts.init($('#mychart')[0]);
					var option = chart_zx_only_bj(xarr);
					mychart.setOption(option);

					//支出明细
				} else if(xtoken == 'pos_output') {
					var zongprice = json.total_price;
					$("#zongprice_num").html('¥' + zongprice);

					totalnum = json.search_count;
					pagesize = Math.floor(totalnum / pagenum);

					var xarr = json.lists;
					//if(Object.keys(xarr).length==0){
					if(totalnum == 0) {
						$("#box_zhifumingxi1_list").css("background", "url(img/nohave.png)no-repeat center center");
						$("#box_zhifumingxi1_list").css("backgroundSize", "20% auto");
						$("#box_zhifumingxi1_list").css("heigth", "720px");
						$("#box_zhifumingxi1_list").css("margin-top", "2.7rem");
					} else {
						$("#box_zhifumingxi1_list").css("margin-top", "none");
						$("#box_zhifumingxi1_list").css("background", "none");
					}

					$.each(xarr, function(index, item) {
						var add_time = xarr[index].add_time;
						var type_name = xarr[index].type_name;
						var price = xarr[index].price;
						//zongprice += parseFloat(price);
						//var str = (index + 1) + (count - 1) * pagenum;
						var str = "";
						str += '<div class="shuju2_div">';
						str += '<span class="leixin" id="index_type_name">';
						str += '' + type_name + '';
						str += '</span>';
						str += '<div class="clearfix">';
						str += '<span id="index_add_time">';
						str += '' + add_time + '';
						str += '</span><em id="index_price">';
						str += '' + price + '';
						str += '</em></div>';
						str += '</div>';
						$("#box_zhifumingxi1_list").append(str);
					});

					//					console.log(xout);
					//					console.log(count);
					//					console.log(pagenum);
					//					console.log(totalnum);
					//					console.log(pagesize);

				}
				//我的信息
				else if(xtoken == 'notification_lists') {
					totalnum = json.total_count;
					pagesize = Math.floor(totalnum / pagenum);

					var xarr = json.lists;
					//if(Object.keys(xarr).length==0){
					if(totalnum == 0) {
						$("#box_xiaoxi_list").css("background", "url(img/nohave.png)no-repeat center center");
						$("#box_xiaoxi_list").css("backgroundSize", "20% auto");
						$("#box_xiaoxi_list").css("heigth", "720px");
						$("#box_xiaoxi_list").css("margin-top", "2.7rem");
					} else {
						$("#box_xiaoxi_list").css("margin-top", "none");
						$("#box_xiaoxi_list").css("background", "none");
					}

					$("#box_xiaoxi_list").html('')

					$.each(xarr, function(index, item) {
						var add_time = formatDate((new Date(parseInt(xarr[index].add_time) * 1000)), 'yyyy-MM-dd HH:mm:SS');
						//add_time=formatDate(add_time,'yyyy-mm-dd hh24:mi:ss');

						var request_datetime = xarr[index].data.request_datetime;
						var type1 = xarr[index].type;
						var img = xarr[index].data.avatar;
						var str = '';
						//var str = (index+1)+(count-1)*pagenum;

						
						
						
						if(type1 == "warning") {
							str += '<div class="ruqin">';
							str += '	<div class="top clearfix">';
							str += '		<em>' + xarr[index].data.title + '</em>';
							str += '		<span>' + add_time + '</span>';
							str += '	</div>';
							str += '	<div class="mid clearfix">';
							str += '		<img src="' + img + '" alt="" />';
							str += '		<div class="right">';
							str += '			<div class="right1">入侵人员：<em class="em1">' + xarr[index].data.real_name + '</em>';
							str += '			</div>';
							str += '			<span class="right1">时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;间：<em>' + request_datetime + '</em></span>';
							str += '		</div>';
							str += '	</div>';
							str += '	<div class="bot clearfix">';
							str += '		<a href="tel:+' + xarr[index].data.manager_phone + '">呼叫负责人</a>';
							str += '		<a href="store_luxiangchakan.html">查看监控</a>';
							str += '	</div>';
							str += '</div>';
						} else if(type1 == "bind") {
							var is_complete = xarr[index].data.is_complete;
							str += '<div class="bangding">';
							str += '	<div class="top clearfix">';
							str += '		<em>' + xarr[index].data.title + '</em>';
							str += '		<span>' + add_time + '</span>';
							str += '	</div>';
							str += '	<div class="mid clearfix">';
							str += '		<div>申请人员：<span>' + xarr[index].data.real_name + '</span></div>';
							str += '		<div>加入门店：<span>' + xarr[index].data.shop_name + '</span></div>';
							str += '		<div>申请时间：<span>' + request_datetime + '</span></div>';
							str += '	</div>';
							if(is_complete != "1") {
								str += '	<div class="bot clearfix">';
								str += '		<a href="javascript:staff_modify_apply(0,' + xarr[index].shop_id + ',' + xarr[index].user_id + ',' + xarr[index].id + ');">不同意</a>';
								str += '		<a href="javascript:staff_modify_apply(1,' + xarr[index].shop_id + ',' + xarr[index].user_id + ',' + xarr[index].id + ');">同意</a>';
								str += '	</div>';
							}

							str += '</div>';
						} else if(type1 == "notify") {
							str += '<div class="tongguo">';
							str += '	<div class="top clearfix">';
							str += '		<em>通过审核</em>';
							str += '		<span>' + add_time + '</span>';
							str += '	</div>';
							str += '	<div class="mid clearfix">';
							str += '		<div>加入门店：<span>' + xarr[index].data.bind_shop + '</span></div>';
							str += '		<div>申请时间：<span>' + xarr[index].data.bind_datetime + '</span></div>';
							str += '	</div>';
							str += '</div>';
						}
						$("#box_xiaoxi_list").append(str);

					});

					//我的消息中 同意与不同意处理
				} else if(xtoken == 'staff_modify_apply') {
					//刷新消息列表
					notification_lists(1,20);

				}
				//pos数据录入（已成功，清空数据）
				else if(xtoken == 'pos_write_input') {
					mui("#index_price")[0].value = '';
					mui("#index_fixture_count")[0].value = '';
					mui("#index_sales_count")[0].value = '';
					mui("#index_cost_price")[0].value = '';
					//                

					//<!-------------- - 下面都是店铺的------------------------------------------------------ >

					//店铺的------------获取设备信息-----3.61 获取设备信息
				} else if(xtoken == 'guest_device') {

					var str = '';
					var xarr = json.lists;
					//console.log("=========================================================");
					mui("#box_video_lists")[0].innerHTML = '';
					mui.each(xarr, function(index, item) {
						var thumbnail=xarr[index].thumbnail;

						var te_sn = xarr[index].te_sn;
						var id = xarr[index].id;
						var te_rtsp_1 = xarr[index].te_rtsp_1;
						var te_rtsp_0 = xarr[index].te_rtsp_0;

						str += '<div class="zong" onclick=\'jkck_play("'+id+'","'+te_sn+'","'+te_rtsp_0+'","'+te_rtsp_1+'");\'>';
						str += '<img  src="'+thumbnail+'" alt="" class="tu" />';
						str += '<div class="rili clearfix">';
						str += '<img class="img_left" src="img/zaixian.png" alt="" />';
						str += '<span class="blue">' + xarr[index].name + '（<em>' + xarr[index].te_key + '</em>）</span>';
						//str += '<img class="img_right" src="img/close.png" alt="" />';
						str += '</div>';
						str += '</div>';
					});
					mui("#box_video_lists")[0].innerHTML = str;

					//获取最近到店人员 
				} else if(xtoken == 'guest_lists') {
					mui("#zuijidaodian")[0].innerHTML = '';
					var str = '';
					var xarr = json.lists;
					mui.each(xarr, function(index, item) {
						var name = xarr[index].real_name;
						var avatar = xarr[index].avatar;

						str += '<li class="mui-table-view-cell mui-media mui-col-xs-3">';
						str += '	<a href="client.html?member_id=' + xarr[index].member_id + '">';
						str += '		<img class="mui-media-object" src="' + avatar + '">';
						str += '		<div class="mui-media-body">' + name + '</div>';
						str += '	</a>';
						str += '</li>';
					});
					mui("#zuijidaodian")[0].innerHTML = str;

				//店铺的------------获取回放录像地址
				} else if(xtoken == 'security_video_play') {
					var te_rtsp_link = json.url;
					shishidz(te_rtsp_link);
					mui("#zuijidaodian")[0].innerHTML = '';
					var str = '';
					var xarr = json.member_list;
					mui.each(xarr, function(index, item) {
						var name = xarr[index].real_name;
						var avatar = xarr[index].avatar;

						str += '<li class="mui-table-view-cell mui-media mui-col-xs-3">';
						str += '	<a href="client.html?member_id=' + xarr[index].member_id + '">';
						str += '		<img class="mui-media-object" src="' + avatar + '">';
						str += '		<div class="mui-media-body">' + name + '</div>';
						str += '	</a>';
						str += '</li>';
					});
					mui("#zuijidaodian")[0].innerHTML = str;

				//发送 开始 录像的请求
				} else if(xtoken == 'security_video_add') {
						mui.toast("视频保存成功，请在我的录像里查看");	

				//我的录像
				} else if(xtoken == 'mine_storage_video_lists') {

					totalnum = json.total_count;
					pagesize = Math.floor(totalnum / pagenum);

					var xarr = json.lists;
					//if(Object.keys(xarr).length==0){
					if(totalnum == 0) {
						$("#photo_tupian").css("background", "url(img/nohave.png)no-repeat center center");
						$("#photo_tupian").css("backgroundSize", "20% auto");
						$("#photo_tupian").css("heigth", "720px");
						$("#photo_tupian").css("margin-top", "2.7rem");
					} else {
						$("#photo_tupian").css("margin-top", "none");
						$("#photo_tupian").css("background", "none");
					}

					//如果对象为空
					if($.isEmptyObject(xarr) && pagesize == 1) {
						$("#photo_bianji").css("display", "none");
					}

					$.each(xarr, function(index, item) { //

						var str = '';
						//var str = (index+1)+(count-1)*pagenum;

						var xdate = xarr[index].date;
						str += '<div class="day">';
						str += '<div class="day_div clearfix">';
						str += '	<span>' + xdate + '</span><em data-id=".cl' + xdate + '" style="display: none;" class="today_xuanze">选择</em>';
						str += '</div>';
						str += '<ul class="mui-table-view mui-grid-view clearfix">';
						var str1 = '';
						var y = xarr[index].lists;
						$.each(y, function(i, it) {
							//var img = y[i].thumbnail;
							//var video = y[i].url;
							var img ='https://lypic.gz.bcebos.com/images/20180206/thumbnail.4c0717c9c9ccfc393de7bb3feeed267a.jpg';
							var video='http://video.dianliubao.com/live?te_sn=00e070747d47';
							str1 += '<li class="mui-table-view-cell mui-media mui-col-xs-3">';
							str1 += '	<img data-imgid="#' + y[i].id + '"  class="mui-media-object" src="' + img + '" data-preview-src="video" data-video="'+video+'" data-preview-group="1">';
							str1 += '	<img data-valid="0" id="' + y[i].id + '"  class="xuanzhong cl' + xdate + '" src="img/xuanzhong.png" alt="" />';
							str1 += '</li>';
						});
						str += str1;
						str += '</ul>';
						str += '</div>';
						//
						$("#photo_tupian").append(str);
					});	

				//我的录像--删除录像信息
				} else if(xtoken == 'security_video_delete') {
					mui.toast(data.message);
					//刷新录像
					window.location.reload();
					//刷新录像的选择数量
					select_photo = [];
					$("#select_photo_num").html(select_photo.length);															

					//店铺的------------获取顾客员工比分析
				} else if(xtoken == 'statistics_customerstaffrate') {

					var str = '';
					var xarr = json.graphic.data1;
					//					console.log(xarr);
					//					mui("#index-graphic-data1-name")[0].innerHTML = xarr.name;
					//					chart_zx_only_bj(xarr, 'statistics_turnover1');

					var mychart = echarts.init($('#mychart')[0]);
					var option = chart_zx_only_bj(xarr);
					mychart.setOption(option);

					//店铺的------------获取客流高低峰分析
				} else if(xtoken == 'statistics_passengerflowpeak') {

					var str = '';
					var xarr = json.graphic.data1;

					var mychart = echarts.init($('#mychart')[0]);
					if(xarr.line.length == 2) {
						var option = chart_zx_and_zx_0(xarr);
					} else {
						var option = chart_zx_only_bj(xarr);
					}
					mychart.clear();
					mychart.setOption(option);

					//店铺的------------获取销售时段分析
				} else if(xtoken == 'statistics_timeinterval') {

					var str = '';
					var xarr = json.graphic.data1;

					var mychart = echarts.init($('#mychart')[0]);
					if(xarr.line.length == 2) {
						var option = chart_zx_and_zx_0(xarr);
					} else {
						var option = chart_zx_only_bj(xarr);
					}
					mychart.clear();
					mychart.setOption(option);

					//店铺的------------获取增长率分析
				} else if(xtoken == 'statistics_growthrate') {

					var str = '';
					var xarr = json.graphic.data1;

					var mychart = echarts.init($('#mychart')[0]);
					if(xarr.line.length == 2) {
						var option = chart_zx_and_zx_axLine_y_100(xarr);
					} else {
						var option = chart_zx_only_bj_axLine_y_100(xarr);
					}
					mychart.clear();
					mychart.setOption(option);

					//店铺的------------获取客流滞留分析
				} else if(xtoken == 'statistics_passengerretention') {
					var str = '';
					var xarr = json.graphic.data1;

					var mychart = echarts.init($('#mychart')[0]);
					var option = chart_zx_and_zx_0(xarr);
					mychart.clear();
					mychart.setOption(option);

					if(json.chart.max.datetime != "") {
						var timestamp2 = Date.parse(new Date(json.chart.max.datetime));
						var timestamp3 = formashortdate(timestamp2); //改完后的时间

					} else {
						timestamp3 = "";
					}
					console.log(timestamp3);

					//下面是标签系列
					mui("#index-store-klzlfx-max-name")[0].innerHTML = json.chart.max.name;
					mui("#index-store-klzlfx-max-max_person")[0].innerHTML = json.chart.max.max_person;
					mui("#index-store-klzlfx-max-datetime")[0].innerHTML = timestamp3;

					mui("#index-store-klzlfx-avg-name")[0].innerHTML = json.chart.avg.name;
					mui("#index-store-klzlfx-avg-average_person-1")[0].innerHTML = json.chart.avg.data[0].average_person;
					mui("#index-store-klzlfx-avg-date-1")[0].innerHTML = json.chart.avg.data[0].date;
					mui("#index-store-klzlfx-avg-average_person-2")[0].innerHTML = json.chart.avg.data[1].average_person;
					mui("#index-store-klzlfx-avg-date-2")[0].innerHTML = json.chart.avg.data[1].date;

					//店铺的------------获取坪效信息
				} else if(xtoken == 'statistics_groundeffect') {

					var str = '';
					var xarr = json.graphic.data1;

					var mychart = echarts.init($('#mychart')[0]);
					var option = chart_zx_only_bj(xarr);
					mychart.setOption(option);

					//
					//下面是标签系列
					mui("#index-store-px-groundeffect-name")[0].innerHTML = json.chart.groundeffect.name;
					mui("#index-store-px-shop_area-name")[0].innerHTML = json.chart.shop_area.name; //
					mui("#index-store-px-turnover-name")[0].innerHTML = json.chart.turnover.name;
					//进行色彩的变化与图标变化

					iis_rise('#index-store-px-groundeffect-value', json.chart.groundeffect.is_rise, 1);
					iis_rise('#index-store-px-groundeffect-compare_rate', json.chart.groundeffect.is_rise, 1);
					iis_rise('#index-store-px-groundeffect-pic', json.chart.groundeffect.is_rise, 0);

					mui("#index-store-px-groundeffect-value")[0].innerHTML = json.chart.groundeffect.value;
					mui("#index-store-px-groundeffect-compare_rate")[0].innerHTML = json.chart.groundeffect.compare_rate; //

					//进行色彩的变化与图标变化

					iis_rise('#index-store-px-turnover-value', json.chart.turnover.is_rise, 1);
					iis_rise('#index-store-px-turnover-compare_rate', json.chart.turnover.is_rise, 1);
					iis_rise('#index-store-px-turnover-pic', json.chart.turnover.is_rise, 0);
					mui("#index-store-px-turnover-value")[0].innerHTML = json.chart.turnover.value;
					mui("#index-store-px-turnover-compare_rate")[0].innerHTML = json.chart.turnover.compare_rate;

					//进行色彩的变化与图标变化l因为下面是店铺面积
					mui("#index-store-px-shop_area-value")[0].innerHTML = json.chart.shop_area.value + json.chart.shop_area.unit;
					mui("#index-store-px-shop_area-unit")[0].innerHTML = json.chart.shop_area.value2 + "坪";

					//店铺的------------投次回報率
				} else if(xtoken == 'statistics_forecast') {
					var t_profit = parseFloat(json.forecast_annual_profit);
					var t_price = parseFloat(json.forecast_total_price);
					t_profit = t_profit.toFixed(2);
					t_price = t_price.toFixed(2);

					mui("#index-store-tzcs-forecast_annual_profit")[0].innerHTML = t_profit;
					mui("#index-store-tzcs-forecast_total_price")[0].innerHTML = t_price;
					mui("#index-store-tzcs-return_cycle")[0].innerHTML = json.return_cycle;
					//下面的是图表系列--"投資 回報率"
					var yarr_return_compare_rate = json.return_compare.rate;
					var yarr_return_rate = json.return_rate;
					//chart_pie_pie(yarr_return_compare_rate, yarr_return_rate, 'statistics_turnover3b');
					chart_two_pie(yarr_return_compare_rate, yarr_return_rate, 'mychart');

					//店铺的------------获取周趋势分析
				} else if(xtoken == 'statistics_weektrend') {

					var str = '';
					var xarr = json.graphic.data1;

					var mychart = echarts.init($('#mychart')[0]);
					if(xarr.line.length == 2) {
						var option = chart_zx_and_zx_0(xarr);
					} else {
						var option = chart_zx_only_bj(xarr);
					}
					mychart.clear();
					mychart.setOption(option);

					//店铺的------------获取周权重分析
				} else if(xtoken == 'statistics_weekweight') {

					var str = '';
					var xarr = json.graphic.data1;

					var mychart = echarts.init($('#mychart')[0]);
					var option = chart_zx_and_zx_0(xarr);
					mychart.setOption(option);

					//订单明细或订单流水
				} else if(xtoken == 'order_lists') {

					var zongprice = json.total_price;
					$("#total_price").html('¥' + zongprice);

					totalnum = json.search_count;
					pagesize = Math.floor(totalnum / pagenum);

					var xarr = json.lists;
					//if(Object.keys(xarr).length==0){
					if(totalnum == 0) {
						$("#box_zhifumingxi1_list").css("background", "url(img/nohave.png)no-repeat center center");
						$("#box_zhifumingxi1_list").css("backgroundSize", "20% auto");
						$("#box_zhifumingxi1_list").css("heigth", "720px");
						$("#box_zhifumingxi1_list").css("margin-top", "2.7rem");
					} else {
						$("#box_zhifumingxi1_list").css("margin-top", "none");
						$("#box_zhifumingxi1_list").css("background", "none");
					}

					$.each(xarr, function(index, item) {
						var avatar = xarr[index].avatar;
						var order_datetime = xarr[index].order_datetime;
						var member_name = xarr[index].member_name;
						var order_price = xarr[index].order_price;
						var order_no = xarr[index].order_no;
						//						zongprice += parseFloat(order_price);
						//						zongprice = Math.floor(zongprice * 100) / 100;
						var str = '';
						//var str = (index+1)+(count-1)*pagenum;
						
						str += '<a href="client.html?member_id=' + xarr[index].member_id + '" >';
						str += '<div class="shuju2 clearfix">';
						str += '	<img src="' + avatar + '" alt="" />';
						str += '	<div class="shuju2_div">';
						if(member_name&&member_name!=''){
							str += '		<span class="name">' + member_name + '</span>';
						}else{
							str += '<span class="noname">陌生客</span>';
						}
						
						str += '		<div class="clearfix">';
						str += '			<span class="span_left">' + order_datetime + '</span>';
						str += '			<em>¥' + order_price + '</em>';
						str += '			<span class="span_right">订单金额：</span>';
						str += '		</div>';
						str += '		<span class="bianhao">' + order_no + '</span>';
						str += '	</div>';
						str += '</div>';
						str += '</a>';
						$("#box_zhifumingxi1_list").append(str);
					});

					//					console.log(xout);
					//					console.log(count);
					//					console.log(pagenum);
					//					console.log(totalnum);
					//					console.log(pagesize);

					//< !-------------- - 下面都是客户的------------------------------------------------------ >

					//客户的------------获取客户分析
				} else if(xtoken == 'member_dashboard') {
					//设置标签数值
					mui("#client-ac-total_customer")[0].innerHTML = json.chart.total_customer;
					mui("#client-ac-old_customer")[0].innerHTML = json.chart.old_customer;
					mui("#client-ac-return_customer")[0].innerHTML = json.chart.member;

					//设置图表样式
					//"消费次数"
					var xarr1 = json.graphic.consumption_times;
					//					mui("#client-ac-gct-title")[0].innerHTML = xarr.name;
					//					chart_zz_only_noxAxis(xarr, 'client-ac-gct-chart', 'line');
					var mychart1 = echarts.init($('#mychart1')[0]);
					var option1 = chart_zz_only_noxAxis(xarr1, xiaofeicishu);
					mychart1.setOption(option1);

					//"累计消费金额"
					var xarr2 = json.graphic.consumption_price;
					//					mui("#client-ac-gcp-title")[0].innerHTML = xarr.name;
					//					chart_zz_only_noxAxis(xarr, 'client-ac-gcp-chart', 'line');
					var mychart2 = echarts.init($('#mychart2')[0]);
					var option2 = chart_zz_only_noxAxis_offset(xarr2, leijixiaofeijine);
					mychart2.setOption(option2);

					//"客户流失分布"
					var xarr3 = json.graphic.loss_member;
					//					mui("#client-ac-glm-title")[0].innerHTML = xarr.name;
					//					chart_zz_only_noxAxis(xarr, 'client-ac-glm-chart', 'line');
					var mychart3 = echarts.init($('#mychart3')[0]);
					var option3 = chart_zz_only_noxAxis_offset(xarr3, kehuliushi);
					mychart3.setOption(option3);

					//"客户转化率分布"
					var xarr4 = json.graphic.conversion_rate;
					//					mui("#client-ac-gcr-title")[0].innerHTML = xarr.name;
					//					chart_zz_only_noxAxis(xarr, 'client-ac-gcr-chart', 'line');
					var mychart4 = echarts.init($('#mychart4')[0]);
					var option4 = chart_zz_only_noxAxis_offset(xarr4, kehuzhuanhualv);
					mychart4.setOption(option4);

					//"平均到店周期"
					var xarr5 = json.graphic.average_visit;
					//					mui("#client-ac-gav-title")[0].innerHTML = xarr.name;
					//					chart_zz_only_noxAxis(xarr, 'client-ac-gav-chart', 'line');
					var mychart5 = echarts.init($('#mychart5')[0]);
					var option5 = chart_zz_only_noxAxis_offset(xarr5, pingjundaodian);
					mychart5.setOption(option5);

					//"年龄占比"
					var xarr6 = json.graphic.age_ratio;
					xarr6.name = '客户年龄分布';
					//					mui("#client-ac-gar-title")[0].innerHTML = xarr.name;
					//					chart_zz_only_noxAxis(xarr, 'client-ac-gar-chart', 'line');
					var mychart6 = echarts.init($('#mychart6')[0]);
					var option6 = chart_zz_only_noxAxis(xarr6);
					mychart6.setOption(option6);

					//饼图
					//"会员比"
					var xarr = json.graphic.customer_ratio;
					mui("#client-ac-gcrc-title")[0].innerHTML = '会员分布';
					chart_pie_only(30, xarr.data[0].key, xarr.data[1].key, xarr.data[0].value, xarr.data[1].value, 'client-ac-gcrc-chart');
					//"男女比例"
					var xarr = json.graphic.gender_ratio;
					mui("#client_ac_ggrc_title")[0].innerHTML = '性别比例';
					(xarr.data[0].value == 0) ? xarr.data[0].value = 50: xarr.data[0].value = xarr.data[0].value;
					(xarr.data[1].value == 0) ? xarr.data[1].value = 50: xarr.data[1].value = xarr.data[1].value;
					chart_pie_only(30, xarr.data[0].key, xarr.data[1].key, xarr.data[0].value, xarr.data[1].value, 'main_graphic');

					//客户的------------获取客户列表
				} else if(xtoken == 'member_lists') {
					mui("#client-cs-total_count")[0].innerHTML = json.total_count;
					mui("#client-cs-search_count")[0].innerHTML = json.search_count;

					totalnum = json.search_count;
					pagesize = Math.floor(totalnum / pagenum);

					var xarr = json.lists;
					//if(Object.keys(xarr).length==0){
					if(totalnum == 0) {
						$("#box_merber_lists").css("background", "url(img/nohave.png)no-repeat center center");
						$("#box_merber_lists").css("backgroundSize", "20% auto");
						$("#box_merber_lists").css("heigth", "720px");
						$("#box_merber_lists").css("margin-top", "2.7rem");
					} else {
						$("#box_merber_lists").css("margin-top", "none");
						$("#box_merber_lists").css("background", "none");
					}

					$.each(xarr, function(index, item) {
						var x = xarr[index].visit_time;
						var num = xarr[index].level;
						var name = xarr[index].real_name;
						var nameclass='';
						//console.log(name);
						if((name=="")||(name=="陌生客")){
							name="陌生客";
							nameclass='style="color: #ccc;"';
						}else{
							name=name;
							nameclass='';
						}
						//console.log(nameclass);	
						
						//
						var str = "";
						//var str = (index+1)+(count-1)*pagenum;
						

						var str_li = '<li class="mui-table-view-cell mui-media">';
						str_li += '<a href="client.html?member_id=' + xarr[index].member_id + '" style="width: 100%;">';
						str_li += '<div class="mui-media-object mui-pull-left clearfix">';
						str_li += '<img class="img1" src="' + xarr[index].avatar + '">';
						str_li += '<div class="appraise">';
						//
						for(var i = 0; i < num; i++) {
							str_li += '<img src="img/appraise_yes.png" alt="" />';
						}
						for(var i = 0; i < (5 - num); i++) {
							str_li += '<img src="img/appraise_no.png" alt="" />';
						}

						str_li += '</div>';
						str_li += '</div>';
						str_li += '<div class="mui-media-body kehuxinxi">';
						str_li += '<div class="xingming clearfix">';
						str_li += '<em class="em1" '+nameclass+'>' + name + '</em>';
						var s = 'nv';
						(xarr[index].gender == 0) ? s = 'nv': s = 'nan';
						str_li += '<img class="img10" src="img/' + s + '.png" alt="" />';
						var c = 'active';

						// (xarr[index].is_active == 1) ? c = 'huoyuedl': c = 'huoyue';
						// str_li += '<img src="img/' + c + '.png" alt="" />';

						// (xarr[index].is_new_guest == 1) ? c = 'xinchengjiaodl': c = 'xinchengjiao';
						// str_li += '<img src="img/' + c + '.png" alt="" />';

						(xarr[index].is_member == 1) ? c = 'huiyuandl': c = 'huiyuan';
						str_li += '<img src="img/' + c + '.png" alt="" />';

						// (xarr[index].guest_type == 0) ? c = 'fangkedl' : c = 'fangke';
						// str_li += '<img src="img/' + c + '.png" alt="" />';

						if(xarr[index].guest_type == 0) {
							c = 'fangkedl';
							str_li += '<img src="img/' + c + '.png" alt="" />';
						} else if(xarr[index].guest_type == 1) {
							c = 'laokedl';
							str_li += '<img src="img/' + c + '.png" alt="" />';
						} else if (xarr[index].guest_type == 2)  {
							c = 'huitoukedl';
							//str_li += '<img src="img/' + c + '.png" alt="" />';
						}
						

						str_li += '</div>';
						str_li += '<div class="xiaofei clearfix">';
						str_li += '	<span class="span1">到店<em> ' + xarr[index].visit_count + ' </em>次</span>';
						str_li += '	<span class="span2">累计消费：<em>¥' + xarr[index].price_count + '</em></span>';
						str_li += '</div>';
						str_li += '<div class="zuijin">最近到店 <em>' + x + '</em></div>';
						str_li += '</div>';
						str_li += '</a>';
						str_li += '</li>';
						str += str_li;

						$("#box_merber_lists").append(str);
					});
					
					$('.fetchmark').hide();

					$(".sanye").hide();
					$(".erye").hide();
					$(".yiye").show();
					$(".div_main1").eq(1).show().siblings().hide();
					he = $(".tupian").css('height'); //头部的高度
					$(".ull").css('padding-top', he);

					//获取搜索历史
				} else if(xtoken == 'member_history') {
					mui("#sousuolishi")[0].innerHTML = '';
					var str = '';
					var xarr = json.lists;
					mui.each(xarr, function(index, item) {
						var val = xarr[index];
						str += '<em class=" mui-icon  mui-left sousuolishiem">' + val + '</em>';
					});
					mui("#sousuolishi")[0].innerHTML = str;
					$(".sousuolishiem").click(function() {
						var em = $(this).html();
						$("#xxxx").val(em);
					})

					//kill搜索历史
				} else if(xtoken == 'member_history_delete') {
					//获取搜索历史
					member_history();

					//< !-------------- - 下面都是我的------------------------------------------------------>
					//获取客户资料
				} else if(xtoken == 'member_info') {
					//会员信息
					var str = '';
					var touxiang = json.group_top[0].value;
					var name = json.group_top[1].value;
					var xinxi = json.group_top[2].value;
					var sales = json.group_info_1[0].value; //促销敏感
					var level = json.group_info_1[1].value; //消费水平
					var member = json.group_info_2[0].value;
					var birthday = json.group_info_2[1].value;
					//var phone = json.group_info_2[2].value;
					var height = json.group_info_2[3].value;
					var chest = json.group_info_2[4].value;
					var waistline = json.group_info_2[5].value;
					var arm = json.group_info_2[6].value;
					var size = json.group_info_2[7].value;
					var color = json.group_info_2[8].value;
					var tongue = json.group_info_2[9].value;
					mui("#touxiang")[0].src = touxiang;
					mui("#name")[0].innerHTML = name;
					mui("#xinxi")[0].innerHTML = xinxi;
					mui("#sales")[0].innerHTML = sales;
					mui("#level")[0].innerHTML = level;
					mui("#member")[0].innerHTML = member;
					mui("#birthday")[0].innerHTML = birthday;
					//mui("#phone")[0].innerHTML = phone;
					mui("#height")[0].innerHTML = height;
					mui("#chest")[0].innerHTML = chest;
					mui("#waistline")[0].innerHTML = waistline;
					mui("#arm")[0].innerHTML = arm;
					mui("#size")[0].innerHTML = size;
					mui("#color")[0].innerHTML = color;
					mui("#tongue")[0].innerHTML = tongue;
					mui("#profession")[0].innerHTML = json.group_info_4[0].value;
					mui("#company")[0].innerHTML = json.group_info_4[1].value;
					mui("#add")[0].innerHTML = json.group_info_4[2].value;
					mui("#shcool")[0].innerHTML = json.group_info_4[3].value;
					mui("#hometown")[0].innerHTML = json.group_info_4[4].value;
					mui("#email")[0].innerHTML = json.group_info_4[5].value;
					mui("#kid")[0].innerHTML = json.group_info_4[6].value;
					//消息记录
					mui("#xiaofeijilu")[0].innerHTML = '';
					//
					var phone = json.group_info_2[2].value;
					var phone2 = str.substr(0, 3) + "****" + str.substr(7, 10);
					mui("#phone")[0].innerHTML = phone2;
					mui("#phone2")[0].value = phone;

					var str = '';
					var order_info1 = json.order_info[0].value;
					var order_info2 = json.order_info[1].value||0;
					var order_info3 = json.order_info[2].value||0;
					str += '<div class="gao clearfix"><span>累计消费</span><em>¥' + order_info1 + '</em></div>';
					str += '<div class="gao clearfix"><span>上次消费</span><em>¥' + order_info2 + '</em></div>';
					str += '<div class="gao clearfix" style="border-bottom: 5px solid #f2f2f2;width: 100%;margin-left: 0;">';
					str += '<span style="margin-left: 5%;">客单均价</span><em>¥' + order_info2 + '</em></div>';
					var xarr = json.order_lists;
					mui.each(xarr, function(index, item) {
						var date_time = xarr[index].datetime;
						var id = xarr[index].info[0].value;
						var price = xarr[index].info[1].value;
						var shangpin = xarr[index].info[2].value;
						var count = xarr[index].info[2].count;

						str += '<div class="zong  clearfix">';
						str += '	<div class="time1 clearfix"><img src="img/time.png" alt="" /><span>' + date_time + '</span></div>';
						str += '	<div class="xiangxi">';
						str += '		<div style="margin-top: 0.06rem;"><span>订单号：</span><em class="em1">' + id + '</em></div>';
						str += '		<div style="margin-top: 0.02rem;"><span>消费金额：</span><em class="em2">¥' + price + '</em></div>';
						str += '		<div style="margin-top: 0.02rem;margin-bottom: 0.08rem;"><span>购买商品（<em class="em3">' + count + '</em>）：</span><em>' + shangpin + '</em></div>';
						str += '	</div>';
						str += '</div>';

					});
					mui("#xiaofeijilu")[0].innerHTML = str;

					//获取用户的品牌偏好
					mui("#pinpailiebiao")[0].innerHTML = '';
					var str = '';
					var xarr = json.group_info_3.data;
					//console.log(xarr);
					mui.each(xarr, function(index, item) {
						var logo = xarr[index].logo;
						str += '<li class="mui-table-view-cell mui-media mui-col-xs-3">';
						str += '    <a href="#">';
						str += '        <img class="mui-media-object" id="pinpai" src="' + logo + '">';
						str += '    </a>';
						str += '</li>';
					});
					mui("#pinpailiebiao")[0].innerHTML = str;

					//到店记录
					mui("#leijidaodian")[0].innerHTML = '';
					var str = '';
					var visit_info1 = json.visit_info[0].value;
					var visit_info2 = json.visit_info[1].value;
					str += '<div class="gao clearfix"><span>累积到店</span><em>' + visit_info1 + '次</em></div>';
					str += '<div class="gao clearfix" style="border-bottom: 5px solid #eee;width: 100%;margin-left: 0;"><span style="margin-left: 5%;">到店周期</span><em>' + visit_info2 + '</em></div>';
					var xarr = json.visit_list;
					mui.each(xarr, function(index, item) {
						var datetime = xarr[index].datetime;
						var price = xarr[index].price;
						var avatar = xarr[index].avatar;
						str += '<div class="xinxi clearfix"><img data-preview-src="" data-preview-group="1" src="' + avatar + '" alt="" /><span>' + datetime + '</span></div>';

					});
					mui("#leijidaodian")[0].innerHTML = str;

					//获取客户的标签
					var str = '';
					var xarr = json.group_info_tags.data;
					$.each(xarr, function(index, item) {
						if(GetLength(xarr[index]) > 8) {
							str = '<em class="erhangem"><span class="erhangspan">' + xarr[index] + '</span></em>';
						} else {
							str = '<em class="yihangem"><span>' + xarr[index] + '</span></em>';
						}
						$("#main").append(str);
					});
					if(Object.keys(xarr).length > 0) {
						//小球碰撞
						group_info_tags();

					} else {
						str = '<em class="yihangem" style="opacity:0;"></em>';
						$("#main").append(str);
						//小球碰撞
						group_info_tags();
					}

					//获取灵友列表 
				} else if(xtoken == 'utils_brand') {
					mui("#pinpailiebiao")[0].innerHTML = '';
					var str = '';
					var xarr = json.lists;
					console.log(xarr);
					mui.each(xarr, function(index, item) {
						var logo = xarr[index].logo;
						str += '<li class="mui-table-view-cell mui-media mui-col-xs-3">';
						str += '    <a href="#">';
						str += '        <img class="mui-media-object" id="pinpai" src="' + logo + '">';
						str += '    </a>';
						str += '</li>';
					});
					mui("#pinpailiebiao")[0].innerHTML = str;

					//我的相册--删除相册信息
				} else if(xtoken == 'mine_storage_delete') {
					mui.toast(data.message);
					//刷新相册
					//mine_storage_lists(count, pagenum);
					window.location.reload();
					//刷新图片的选择数量
					select_photo = [];
					$("#select_photo_num").html(select_photo.length);


					//我的相册
				} else if(xtoken == 'mine_storage_lists') {

					totalnum = json.total_count;
					pagesize = Math.floor(totalnum / pagenum);

					var xarr = json.lists;
					//if(Object.keys(xarr).length==0){
					if(totalnum == 0) {
						$("#photo_tupian").css("background", "url(img/nohave.png)no-repeat center center");
						$("#photo_tupian").css("backgroundSize", "20% auto");
						$("#photo_tupian").css("heigth", "720px");
						$("#photo_tupian").css("margin-top", "2.7rem");
					} else {
						$("#photo_tupian").css("margin-top", "none");
						$("#photo_tupian").css("background", "none");
					}

					

					//如果对象为空
					if($.isEmptyObject(xarr) && pagesize == 1) {
						$("#photo_bianji").css("display", "none");
					}

					$.each(xarr, function(index, item) { //
						
						
						var str = '';
						//var str = (index+1)+(count-1)*pagenum;

						var xdate = xarr[index].date;
						str += '<div class="day">';
						str += '<div class="day_div clearfix">';
						str += '	<span>' + xdate + '</span><em data-id=".cl' + xdate + '" style="display: none;" class="today_xuanze">选择</em>';
						str += '</div>';
						str += '<ul class="mui-table-view mui-grid-view clearfix">';
						var str1 = '';
						var y = xarr[index].lists;
						$.each(y, function(i, it) {
							var img = y[i].thumbnail;
							str1 += '<li class="mui-table-view-cell mui-media mui-col-xs-3">';
							str1 += '	<img data-imgid="#' + y[i].id + '"  class="mui-media-object" src="' + img + '" data-preview-src="" data-preview-group="1">';
							str1 += '	<img data-valid="0" id="' + y[i].id + '"  class="xuanzhong cl' + xdate + '" src="img/xuanzhong.png" alt="" />';
							str1 += '</li>';
						});
						str += str1;
						str += '</ul>';
						str += '</div>';
						//
						$("#photo_tupian").append(str);
					});

				   /*
					//mui触屏点击
					$(".today_xuanze").on('tap', 'em', function(event) {
						//$(".today_xuanze").click(function() { //点击选择按钮
						var tmpbtncl = $(this).data("id");
						if($(this).html().indexOf("选择") != -1) {
							//显示全部选中
							$(tmpbtncl).css('display', 'block');
							$(tmpbtncl).data("valid", "1");
							$(this).html("取消");
						} else {
							//取消全部选中
							$(tmpbtncl).css('display', 'none');
							$(tmpbtncl).data("valid", "0");
							$(this).html("选择");
						}
						//统计被选择的图片
						btn_xuanzhong();
					});

					//mui触屏点击
					$(".mui-media-object").on('tap', 'img', function(event) {
						//$(".mui-media-object").click(function() { //点击单张图片按钮
						var tmpimgcl = $(this).data("imgid");
						var tdisplay = $(tmpimgcl).css('display');
						if($("#photo_bianji").html().indexOf("完成") != -1) {
							if(tdisplay == 'none') {
								$(tmpimgcl).show();
								$(tmpimgcl).data("valid", "1");
							} else {
								$(tmpimgcl).hide();
								$(tmpimgcl).data("valid", "0");
							}
						}
						//统计被选择的图片
						btn_xuanzhong();
					});
				   */
					//我的门店	
				} else if(xtoken == 'shop_lists_me_stone') {

					var str = '';
					var xarr = json.lists;

					if(xarr.length == 0) {
						//登录成功，将用户信息进行本地储存
						if(shop_value_select('data.lookshop_name', 'data.lookshop_id')) {
							storage["id"] = user_info.id; //===========================================================有用吗？							
							window.location.href = "reg_user_loginnot.html"; //-------------------------------------------不用跳转了
							return;
						}

					} else {

						//将存储成 json对象
						user_info.shop_list = json.lists;
						window.localStorage.setItem("user_info", JSON.stringify(user_info));

						mui("#mine-shop-lists")[0].innerHTML = '';
						mui.each(xarr, function(index, item) {
							str += '<div class="line-wrapper shoplists" data-roleid="' + xarr[index].role_id + '"  data-shopimg="imgid' + xarr[index].shop_id + '"  data-shopname="' + xarr[index].shop_name + '"  data-shopid="' + xarr[index].shop_id + '">';
							str += '    <div class="line-scroll-wrapper">';
							str += '        <div class="line-normal-wrapper clearfix">';
							str += '            <div class="line-normal-user-name">' + xarr[index].shop_name;
							str += '<span style="color:#CCCCCC;margin-left:0.15rem;">(ID:' + xarr[index].id + ')</span>' + '</div>';

							//判断用户删除了打勾的门店
							if(tmpdelid == "data.lookshop_id") {
								if(index == 0) {
									//登录成功，将用户信息进行本地储存,并且将现有的第1个门店打上勾
									if(shop_value_select(xarr[index].shop_name, xarr[index].shop_id)) {
										str += '           <img class="imgclass" id="imgid' + xarr[index].shop_id + '" src="img/dagou.png"/>';
									};
								} else {
									str += '           <img class="imgclass" id="imgid' + xarr[index].shop_id + '" src="img/dagoumr.png"/>';
								};
							} else {
								if(user_info.look_shop_id == xarr[index].shop_id) {
									str += '           <img class="imgclass" id="imgid' + xarr[index].shop_id + '" src="img/dagou.png"/>';
									//判断是否显示店员管理
									if (xarr[index].role_id != "3") {
										$("#me_store_editor").show();
									} else {
										$("#me_store_editor").hide();
									}
									$("#me_store_editor").attr("href", "me_store_editor.html?staff_lists_shopid=" + xarr[index].shop_id);
								} else {
									str += '           <img class="imgclass" id="imgid' + xarr[index].shop_id + '" src="img/dagoumr.png"/>';
								};
							}

							str += '        </div>';
							str += '        <button class="line-btn-delete" data-userid="' + xarr[index].id + '" ';
							str += 'data-shopname="' + xarr[index].shop_name + '"  data-shopid="' + xarr[index].shop_id + '">解绑</button>';
							str += '    </div>';
							str += '</div>';
						});
						mui("#mine-shop-lists")[0].innerHTML = str;


						//变更 门店的选看ID
						$(".line-wrapper.shoplists").on("click", function() {
							var tmp_shop_id = $(this).data("shopid");
							var tmp_shop_name = $(this).data("shopname");
							var tmp_imgid = $(this).data("shopimg");
							var tmp_role_id = $(this).data("roleid");
							//登录成功，将用户信息进行本地储存
							if(shop_value_select(tmp_shop_name, tmp_shop_id)) {
								//变更显示的门店标签
								$(".imgclass").attr("src", "img/dagoumr.png");
								$("#" + tmp_imgid).attr("src", "img/dagou.png");
								//判断是否显示店员管理
								if(tmp_role_id != "3") {
									$("#me_store_editor").show();
								} else {
									$("#me_store_editor").hide();
								}
								$("#me_store_editor").attr("href", "me_store_editor.html?staff_lists_shopid=" + tmp_shop_id);
							};
						});

						//开始刷新**********************
						shop_list_xbxline();

						//解除绑定-----解除对应门店的职务(
						$(".line-btn-delete").on("click", function() {
							var xbx = {};
							xbx.shop_id = $(this).data("shopid"); //选择的店铺ID

							if(xbx.shop_id == user_info.look_shop_id) {
								//说明删除的是用户当前选择的门店，因此要系统刷新后，给用户分配一个新的门店
								tmpdelid = 'data.lookshop_id';
							} else {
								tmpdelid = '0';
							}
							//登录后的参数对象AES加密
							//3.38 解除绑定门店
							official_login_after(url_host + 'mine/unbind', xbx, 'mine_unbind');

						});
					};

					////获取当前的人事管理职员列表
				} else if(xtoken == 'staff_lists') {

					var str = '';
					var xarr = json.lists;

					mui("#mine-shop-lists")[0].innerHTML = '';
					mui.each(xarr, function(index, item) {
						str += '<div class="line-wrapper shoplists" data-userid="' + xarr[index].id + '" data-realname="' + xarr[index].real_name + '">';
						str += '    <div class="line-scroll-wrapper">';
						str += '        <div class="line-normal-wrapper clearfix">';
						str += '            <div class="line-normal-user-name">' + xarr[index].real_name + '</div>';
						str += '           <img class="imgclass" id="imgid' + xarr[index].id + '" src="img/dagoumr.png"/>';
						str += '        </div>';
						str += '        <button class="line-btn-delete" data-userid="' + xarr[index].id + '" data-realname="' + xarr[index].real_name + '">解绑</button>';
						str += '    </div>';
						str += '</div>';
					});
					mui("#mine-shop-lists")[0].innerHTML = str;
					//开始刷新**********************
					shop_list_xbxline();

					//3.64 解除绑定-----解除对应门店的职员(
					$(".line-btn-delete").on("click", function() {
						var xbx = {};
						xbx.shop_id = parseInt(staff_lists_shopid); //选择的店铺ID
						xbx.user_id = $(this).data("userid"); //用户ID

						official_login_after(url_host + 'staff/modify/unbind', xbx, 'staff_modify_unbind');

						//刷新-----人事管理职员列表
						staff_lists();

					});

					//					//解除绑定-----解除对应门店的职员，权限是店长与管理员
					//				} else if(xtoken == 'staff_modify_unbind') {
					//					var xbx = {};
					//					xbx.shop_id = $(this).data("shopid"); //选择的店铺ID		
					//
					//					official_login_after(url_host + 'staff/modify/unbind', xbx, 'staff_modify_unbind');

					//我的个人资料-昵称修改	
				} else if(xtoken == 'mine_modify_mine_name') {
					user_info.real_name = mui('#mine-name')[0].value;
					//将存储成 json对象
					window.localStorage.setItem("user_info", JSON.stringify(user_info));
					window.location.href = "me_editor.html";

					//我的个人资料-头像修改	
				} else if(xtoken == 'mine_modify_mine_logo') {

					//我的个人资料-修改密码
				} else if(xtoken == 'mine_modify_password') {
					mui.toast(data.message);
					window.location.href = "reg_user_login.html";

				} else if(xtoken == 'mine_avatar_upload') {
					mui.alert(data.message);

				} else if(xtoken == 'mine_bind_position') {
					//登录成功后---------------获取-->更新门店的职务列表
					bind_position_arr = json.lists;
					//console.log(bind_position_arr);

					//mine_bind_demo申请加入体验店 ，是在登陆后
				} else if(xtoken == 'mine_bind_demo') {
					//登录体验店就是直接登录login
					var sbx = {};
					sbx.id = user_info.params_sbx.id;
					sbx.password = user_info.params_sbx.password; //已经经过了加密
					//					sbx.password = md5(sbx.password);
					//					sbx.password = sbx.password.toLowerCase();

					login_encrypt_md5(sbx);
					console.log(sbx);
					ajax_submit_before(url_host + 'user/login', 'user_login');

					//mine_bind申请加入门店 ，是在登陆后=========================================//
				} else if(xtoken == 'mine_bind') {
					var mess = '<div style="height:60px;line-height:60px;width:100%">您的申请已提交，请耐心等待！</div>'; //待店铺审核通过后重新登录即可看到新增店铺数据
					mui.alert(mess, "", "知道了", function() {
						window.location.href = 'me_store.html';
					});

					//mine_unbind ，是在登陆后解约门店的
				} else if(xtoken == 'mine_unbind') {
					mui.alert(data.message);

					//重新刷新一下在解约门店后-----------获取我的门店
					shop_lists_me_stone();

					//这是 要解除 职员的绑定功能啊。。。。。。。。。。。。。。。。。。。。。。。
				} else if(xtoken == 'staff_modify_unbind') {
					mui.alert(data.message);
					//window.location.reload();
					//console.log(data.data);

				} else {
					mui.alert(data.message);
					console.log(data.data);
				}

			} else {
				mui.alert(data.message);
				console.log(data.status);
				//隐藏加载动画
				$('.fetchmark').hide();
				if(data.status == 400) {
					if(xtoken == 'mine_bind_position') {
						//职务表清空
						bind_position_arr = {};
						position_json = [];
						mui("#shop_postion")[0].innerHTML = '';
						mui("#shop_postion_id")[0].value = '';
						$("#shop_postion").addClass("ccc");
						$("#shop_postion").html("请选择您的门店职务");
						document.getElementById("btn_login").disabled = true;

					} else if(xtoken == 'security_video_add') {
						mui.toast("视频保存失败-400");
						console.log(data);

					}
				} else if(data.status == 401) {
					if(xtoken == 'security_video_add') {
						mui.toast("视频保存失败-401");
						console.log(data);
					} else {
						window.location.href = "reg_user_login.html";
					}

				};
			}

		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
			//隐藏加载动画
			$('.fetchmark').hide();
		}
	});
}

//登录前的对象ajax提交
function ajax_submit_before(xurl, token) {
	console.log(xurl + "---->");
	console.log("");
	mui.ajax(xurl, {
		data: {
			'client': obj.client,
			'version': obj.version,
			'params': obj.params
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		success: function(data) {
			//服务器返回响应，根据响应结果，分析是否登录成功；
			console.log(data,obj);
			console.log(xurl + "-----------");
			if(data.status == 200) {
				if(token == 'user_login') {
					//登录成功，将用户信息进行本地储存
					//存储到loaclStage   

					user_info.avatar = data.data.user_info.avatar;
					user_info.email = 'data.editor.email';
					user_info.gender = 'data.editor.gender';
					user_info.phone = data.data.user_info.id;
					user_info.real_name = 'data.data.real_name';
					user_info.token = data.data.token;
					user_info.look_shop_id = 'data.lookshop_id';
					user_info.look_shop_name = 'data.lookshop_name';
					//user_info.look={};
					user_info.shop_list = data.data.shop_list; //{id: 1, shop_name: "demo", position_id: 3, position_name: "职员", role_id: 3}
					user_info.id = data.data.user_info.id;
					user_info.user_id = data.data.user_info.user_id;
					user_info.secret_accept = data.data.secret.accept;
					user_info.secret_response = data.data.secret.response; //{accept: "1234567890123456", response: "1234567890123456"}
					user_info.agree = data.data.user_info.agree;

					
					//将存储成 json对象
					window.localStorage.setItem("user_info", JSON.stringify(user_info)); //但是返回[object Object]
					if(user_info.agree==0){
						location.href = 'index_protocol.html'
						return
					}
					if(data.data.shop_list.length > 0) {
						window.location.href = "index.html";
					} else {
						storage["id"] = user_info.id; //===========================================================有用吗？
						window.location.href = "reg_user_loginnot.html";
					}

				}else if(token == 'user_check_id') {
					//验证号码有效性->有效的话，把前端的提交按钮激活
					res_login = 1;
					document.getElementById("btn_login").disabled = false;
					mui("#forgetPassword")[0].innerHTML = '&nbsp;';

				} else if(token == 'user_join') {
					//注册成功-->跳转到 发送注册验证码
					//存储到loaclStage   
					storage["register_phone"] = mui('#account')[0].value;
					window.location.href = "reg_user_join_code.html";

				} else if(token == 'user_join_again') {
					//注册时， 重发验证码成功-->修改页面 文字 提示
					mui("#forgetPassword")[0].innerHTML = '<span id="time3">45</span><span style="color: #000000;">秒后，重发验证码</span>';
					//定时
					time1();

				} else if(token == 'user_join_code') {
					//验证码验证成功-->跳转到  设备用户的新密码
					//存储到loaclStage   
					storage["auth_token"] = data.data.auth_token;
					window.location.href = "reg_user_join_add_setpsw.html";

				} else if(token == 'join_add_setpsw') {
					//用户提交了 新密码后--->直接跳转到  添加用户
					window.location.href = "reg_user_join_add.html";

				} else if(token == 'user_join_add') {
					//用户的信息资料提交成功后--->直接跳转到   用户绑定门店
					window.location.href = "reg_user_bind.html";

				} else if(token == 'user_bind') {
					//成功绑定了门店->跳转到绑定成功界面
					window.location.href = "reg_bindingsuccess.html";

				} else if(token == 'bind_position') {
					//成功获取门店注册时获取职务列表-->更新门店的职务列表
					bind_position_arr = data.data.lists;

				} else if(token == 'user_bind_demo') {
					//登录体验店就是直接登录login
					var sbx = {};
					sbx.id = storage["id"];
					sbx.password = storage["register_psw"];
					sbx.password = md5(sbx.password);
					sbx.password = sbx.password.toLowerCase();

					login_encrypt_md5(sbx);
					console.log(sbx);
					ajax_submit_before(url_host + 'user/login', 'user_login');

					//加入体验店

				} else if(token == 'user_find') {
					//忘记密码提交成功-->跳转到 发送  找回密码验证码
					//存储到loaclStage   
					storage["register_phone"] = mui('#account')[0].value;
					window.location.href = "reg_user_find_code.html";

				} else if(token == 'user_find_again') {
					//注册时， 重发验证码成功-->修改页面 文字 提示
					mui("#forgetPassword")[0].innerHTML = '<span id="time3">45</span><span style="color: #000000;">秒后，重发验证码</span>';
					//定时
					time1();

				} else if(token == 'user_find_code') {
					//验证码验证成功-->跳转到  设备用户的新密码
					//存储到loaclStage   
					storage["auth_token"] = data.data.auth_token;
					window.location.href = "reg_user_find_reset.html";

				} else if(token == 'user_find_reset') {
					//修改密码成功-->跳转到  修改成功页面
					window.location.href = "reg_updatesuccess.html";

				} else if(token == 'bind_demo') {
					//提交加入demo体验店成功-->跳转到 登录页面
					window.location.href = "index.html";

				} else {
					mui.alert(data.message);
				}
			} else {
				if(token == 'user_check_id') {
					//验证号码有效性->无效的话，把前端的提示内容激活
					document.getElementById("btn_login").disabled = false;
					mui("#forgetPassword")[0].innerHTML = '您输入的账号不存在，请重新输入';

				} else if(token == 'bind_position') {
					mui.alert(data.message);

					//职务表清空
					bind_position_arr = {};
					position_json = [];
					mui("#shop_postion")[0].innerHTML = '';
					mui("#shop_postion_id")[0].value = 0;
					$("#shop_postion").addClass("ccc");
					$("#shop_postion").html("请选择您的门店职务");
					document.getElementById("btn_login").disabled = true;

				} else if(token == 'user_join_code') {
					mui.alert('', "<div style='height:60px;line-height:60px;width:100%'>验证码输入错误，请重新输入</div>", "<div style='color:#4198ff'>重新输入</div>");

				} else if(token == 'user_find_code') {
					mui.alert('', "<div style='height:60px;line-height:60px;width:100%'>验证码输入错误，请重新输入</div>", "<div style='color:#4198ff'>重新输入</div>");

				} else {
					res_login = 0;
					mui.alert(data.message);
				}

			}

		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}
	});
}

//排序算法a-z;
function objKeySort(arys) {
	//先用Object内置类的keys方法获取要排序对象的属性名，再利用Array原型上的sort方法对获取的属性名进行排序，newkey是一个数组
	var newkey = Object.keys(arys).sort();
	var newObj = ''; //创建一个新的对象，用于存放排好序的键值对
	for(var i = 0; i < newkey.length; i++) {
		//遍历newkey数组  拼接成 a='12'&b={}& 如果是对象或者数组的时候转换JSON
		newObj += newkey[i] + '=' + (typeof arys[newkey[i]] == "object" ? JSON.stringify(arys[newkey[i]]) : arys[newkey[i]]) + '&';
		// newObj[newkey[i]] = arys[newkey[i]]; 
		//向新创建的对象中按照排好的顺序依次增加键值对
	}
	return newObj.slice(0, newObj.length - 1); //返回排好序的新对象
}

//数据AES加密
function encrypt_xaccept(xaccept, xparams) {
	//优先在vuex里面取值防止localstange被清除  
	var keyAccept = CryptoJS.enc.Utf8.parse(xaccept);
	var str = CryptoJS.AES.encrypt(JSON.stringify(xparams), keyAccept, {
		mode: CryptoJS.mode.ECB
	}).toString();
	return str
}

//数据AES解密
function decrypt_xaccept(xresponse, xencrypt) {
	//优先在vuex里面取值防止localstange被清除  
	var keyAccept = CryptoJS.enc.Utf8.parse(xresponse);
	var str = CryptoJS.AES.decrypt(JSON.stringify(xencrypt), keyAccept, {
		mode: CryptoJS.mode.ECB
	}).toString();
	return str
}

//验证账号-通过手机号判断手机号是否注册
function user_check_id(phone) {

	var sbx = {};
	sbx.id = phone

	login_encrypt_md5(sbx);
	console.log(sbx);
	ajax_submit_before(url_host + 'user/check/id', 'user_check_id');
}

/*校验一个字符串中的内容是否是手机号*/
function isPhoneNumber(phoneNumStr) {
	var reg = new RegExp("^(13|15|18)[0-9]{9}$");
	return reg.test(phoneNumStr) ? true : false;
}

function datebian(num, dateValue) {
	var cDate = stringToDate(dateValue);
	cDate.setDate(cDate.getDate() + num);
	currentDate = formatDate(cDate, "yyyy-MM-dd"); //改完后的时间
	return currentDate;
}

  
function stringToDate(fDate) {     
	var fullDate = fDate.split("-");          
	return new Date(fullDate[0], fullDate[1] - 1, fullDate[2], 0, 0, 0);   
}

function formatDate(date, format) {
	var v = "";
	if(typeof date == "string" || typeof date != "object") {
		return;
	}
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var day = date.getDate();
	var hour = date.getHours();
	var minute = date.getMinutes();
	var second = date.getSeconds();
	var weekDay = date.getDay();
	var ms = date.getMilliseconds();
	var weekDayString = "";
	if(weekDay == 1) {
		weekDayString = "星期一";
	} else if(weekDay == 2) {
		weekDayString = "星期二";
	} else if(weekDay == 3) {
		weekDayString = "星期三";
	} else if(weekDay == 4) {
		weekDayString = "星期四";
	} else if(weekDay == 5) {
		weekDayString = "星期五";
	} else if(weekDay == 6) {
		weekDayString = "星期六";
	} else if(weekDay == 7) {
		weekDayString = "星期日";
	}

	v = format;
	//Year 
	v = v.replace(/yyyy/g, year);
	v = v.replace(/YYYY/g, year);
	v = v.replace(/yy/g, (year + "").substring(2, 4));
	v = v.replace(/YY/g, (year + "").substring(2, 4));
	//Month 
	var monthStr = ("0" + month);
	v = v.replace(/MM/g, monthStr.substring(monthStr.length - 2));
	//Day 
	var dayStr = ("0" + day);
	v = v.replace(/dd/g, dayStr.substring(dayStr.length - 2));
	//hour 
	var hourStr = ("0" + hour);
	v = v.replace(/HH/g, hourStr.substring(hourStr.length - 2));
	v = v.replace(/hh/g, hourStr.substring(hourStr.length - 2));
	//minute 
	var minuteStr = ("0" + minute);
	v = v.replace(/mm/g, minuteStr.substring(minuteStr.length - 2));
	//Millisecond 
	v = v.replace(/sss/g, ms);
	v = v.replace(/SSS/g, ms);
	//second 
	var secondStr = ("0" + second);
	v = v.replace(/ss/g, secondStr.substring(secondStr.length - 2));
	v = v.replace(/SS/g, secondStr.substring(secondStr.length - 2));
	//weekDay 
	v = v.replace(/E/g, weekDayString);
	return v;
}

//登录前的加密方式
function login_encrypt_md5(sbx) {
	user_info.params_sbx = sbx; //本人账号&密码	
	console.log(user_info.params_sbx);
	//将存储成 json对象
	window.localStorage.setItem("user_info", JSON.stringify(user_info)); //但是返回[object Object]

	obj.client = var_client;
	obj.version = var_version;

	var encrypt = new JSEncrypt();
	encrypt.setPublicKey(publicKey);
	obj.params = encrypt.encryptLong(JSON.stringify(sbx));
	
}

//放在页面 ready成功之后,读入本地的缓存,并且把用户的shopid与shopname写到输入框中
function xminereadyload() {
	console.log(" ");
	console.log("以下是登录后读取存储的----------------user_info-------------------------");

	//登录成功，将用户信息进行本地载入
	user_info = JSON.parse(window.localStorage.getItem("user_info"));

	//如果本地缓存清空
	if(user_info == null) {
		window.location.href = "reg_user_login.html";
	}
	
	if(location.href.indexOf('index_protocol')==-1 && user_info.agree == 0){
		window.location.href = "index_protocol.html";
	}

	//console.log(user_info.shop_list.length);
	//判断当前的href
	var thref = window.location.href;
	if(user_info.shop_list && user_info.shop_list.length == 0 && thref.indexOf('me_user_bind.html') == -1 && thref.indexOf('me_store.html') == -1 && thref.indexOf('reg_user_loginnot.html') == -1) {
		console.log(thref.indexOf('me_store.html'));
		storage["id"] = user_info.id; //===========================================================有用吗？
		//window.location.href = "reg_user_loginnot.html";
	}

	//console.log(user_info);
}

//获取门店列表
function shop_lists_index() {
	var xbx = {}; //登录后的参数对象AES加密
	official_login_after(url_host + 'shop/lists', xbx, 'shop_lists_index');

};

//主要是页面导入完全后初始化配置href的跳转
mui.ready(function() {
	mui('body').on('tap', 'a', function() {
		window.top.location.href = this.href;
	});

	$("#btn_login").addClass("jianbian1_qianse");
	$("#btn_login1").addClass("jianbian1_qianse");
	$("#btn_login2").addClass("jianbian1_qianse");

});

//变更按钮色彩
function btn_login_se(se, btn_obj) {
	if(se == 'qianse') {
		$(btn_obj).removeClass('jianbian3_shengse');
		$(btn_obj).addClass('jianbian1_qianse');
	} else {
		$(btn_obj).removeClass('jianbian1_qianse');
		$(btn_obj).addClass('jianbian3_shengse');
	}
}

//标识弹窗
function time_img(msgalert) {
	var tmpstr = "<div style='font-weight: 400;line-height: 0.20rem;width: 100%;font-size: 0.13rem;color: #4d4d4d;'>{*biaoqiao}</div>";
	tmpstr = tmpstr.replace("{*biaoqiao}", msgalert);
	mui.alert('', tmpstr, "<div style='color: #4198ff;font-weight: 500;font-size: 0.15rem;height: 0.4rem;line-height: 0.4rem;'>我知道了</div>");
};

//第二种（采取将255意外的字符替换成"aa"的做法，取长度）  
function GetLength(str) {
	return str.replace(/[^\x00-\xff]/g, "aa").length;
};